package com.ayf.payment.game.api.controller.platform;

import com.ayf.payment.game.api.dto.platform.MerchantCashOutBatchDTO;
import com.ayf.payment.game.api.dto.platform.MerchantCashOutDTO;
import com.ayf.payment.game.api.dto.platform.criteria.MerchantCashOutCriteria;
import com.ayf.payment.game.api.service.platform.MerchantCashOutService;
import com.ayf.payment.game.api.utils.ExportFileUtil;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 导出文件
 *
 * @author wwl
 * @date 2020/3/12 19:39
 */
@RequestMapping("/t/export")
@RestController
public class ExportMerchantCashOutController {
    @Autowired
    private MerchantCashOutService merchantCashOutService;


    /**
     * 按批次查询付款列表
     * @param merchantCashOutBatchDTO
     * @return
     */
    @GetMapping("/exportCashOutExcel")
    public void exportCashOutExcel(@RequestBody MerchantCashOutBatchDTO merchantCashOutBatchDTO, HttpServletResponse response) throws Exception {
        PageHelper.startPage(1,100);
        MerchantCashOutCriteria selectCriteria =new MerchantCashOutCriteria();
        selectCriteria.setBatcNumber(merchantCashOutBatchDTO.getBatcNumber());
        List<MerchantCashOutDTO> list= merchantCashOutService.getCashOutByBatchList(selectCriteria);
        ExportFileUtil.exportExcel(response,list,selectCriteria.getBatcNumber());
    }

}
